/**
 * 
 */
package projeto.comercial.cliente.cgd;

import javax.persistence.Query;

import org.springframework.stereotype.Repository;

import plataforma.crudestatico.cgd.DaoBase;
import projeto.comercial.cliente.cdp.Cliente;

/**
 * @author mike
 *
 */
@Repository
public class DaoCliente extends DaoBase<Cliente> {

	@Override
	public Cliente recuperarPorId(Long id) {
		String hql = "select distinct c from Cliente c "				
				+ " left outer join fetch c.contatos "
				+ " left outer join fetch c.ramo "
				+ " left outer join fetch c.informacoes " 
				+ " where c.id=:parId ";


		Query query = getEntityManager().createQuery(hql);
		query.setParameter("parId", id);

		return (Cliente) query.getSingleResult();
	}
}
